<?php

namespace App\Http\Requests\Operation;

use App\Http\Requests\Request;

class ContentTemplateDetailsRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'content_template_id' => 'required',
                        'name'                => 'required|max:100',
                        'title'               => 'required|max:100',
                        'subtitle'            => 'required|max:100',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    // $contentTemplate = ContentTemplate::findOrFail($this->route('id'));
                    return [
                        'content_template_id' => 'required',
                        'name'                => 'required|max:100',
                        'title'               => 'required|max:100',
                        'subtitle'            => 'required|max:100',
                    ];
                }
            default:
                break;
        }
    }
    public function messages()
    {
        return [
            'content_template_id.required' => '所属内容模板 不能为空',
            'name.required'       => '名称 不能为空',
            'title.required'       => '标题 不能为空',
            'subtitle.required'     => '副标题 不能为空',
            'name.max'       => '名称 不能大于 :100',
            'title.max'       => '标题 不能大于 :100',
            'subtitle.max'     => '副标题 不能大于 :100',
            
        ];
    } 
}
